//
// Created by entaoyang@163.com on 2021/7/21.
//


import Foundation
import UIKit
import SwiftSweet




extension UIView {


    @discardableResult
    func imageView(block: (UIImageView) -> Void) -> UIImageView {
        addView(UIImageView(image: nil), block)
    }

    @discardableResult
    func label(block: (UILabel) -> Void) -> UILabel{
        addView(UILabel(frame: .zero), block).apply { _ in
//            $0.contentEdgeInsets = EdgeInset(top: 20, left: 30, bottom: 20, right: 30)
        }
    }

    @discardableResult
    func linearVer(block: (LinearLayout) -> Void) -> LinearLayout {
        addView(LinearLayout(.vertical), block)
    }

    @discardableResult
    func linearHor(block: (LinearLayout) -> Void) -> LinearLayout {
        addView(LinearLayout(.horizontal), block)
    }

//
    @discardableResult
    func button(type: UIButton.ButtonType, block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: type), block)
    }

    @discardableResult
    func button(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(frame: .zero), block)
    }

    @discardableResult
    func buttonRounded(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .roundedRect), block)
    }

    @discardableResult
    func buttonCustom(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .custom), block)
    }

    @discardableResult
    func buttonClose(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .close), block)
    }

    @discardableResult
    func buttonContactAdd(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .contactAdd), block)
    }

    @discardableResult
    func buttonSystem(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .system), block)
    }

    @discardableResult
    func buttonInfoLight(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .infoLight), block)
    }

    @discardableResult
    func buttonInfoDark(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .infoDark), block)
    }

    @discardableResult
    func buttonDisclosure(block: (UIButton) -> Void) -> UIButton {
        addView(UIButton(type: .detailDisclosure), block)
    }
}

